let echarts = require('echarts')
require('../../assets/css/reset.css')
require('../../assets/css/normalize.css')
require('../../assets/iconf/iconfont.css')
require('./sportData.less')

let axios = require('axios')
const { color } = require('echarts')
// 获取登录时储存的用户信息
let user = JSON.parse(localStorage.getItem('login'))

// 设置axios请求头,添加token
axios.defaults.headers.authorization = "Bearer " + user.token;

let backi = document.querySelector('.backi')

// 基于准备好的dom，初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));

// 指定图表的配置项和数据
var option = {
  // 标题
  title: {
    text: '近七天运动时长'
  },
  // 提示框
  tooltip: {},

  // legend: {
  //   data: ['销量'],
  // },
  xAxis: {
    data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'],
    nameTextStyle: {
      // color:'#0f0'
    }
  },
  // y轴上的文字
  yAxis: {},
  series: [
    {
      name: '销量',
      type: 'bar',
      data: [5, 20, 36, 10, 10, 20],
      itemStyle: {
       

      }

    }
  ]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);



var myChart = echarts.init(document.getElementById('mainTow'));

optionTow = {
  title: {
    text: '运动分类',
    left: 'left'
  },
  color:['#999','#0f0','#f00'],
  tooltip: {
    trigger: 'item'
  },
  legend: {
    orient: 'vertical',
    left: 'left',
    top:'150',
    itemWidth: 10,
    itemHeight: 10,
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: '50%',
      data: [
        { value: 20, name: '跑步',},
        { value: 30, name: '骑行',},
        { value: 50, name: '训练',},
      ],
      label:{
        position: 'inside',
        color:'#fff',     
         formatter:'{d}%'
      },
      // 视觉引导线
      labelLine:{
        // 不显示
        show:false
      },
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
};

myChart.setOption(optionTow);

backi.addEventListener('click',function(){
  history.go(-1)
})